package com.ytc.mine.controller;

import com.ytc.mine.model.Resume;
import com.ytc.mine.service.ResumeService;
import com.ytc.user.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

//简历
@Controller
@RequestMapping("resume")
public class ResumeController{

    @Autowired
    private ResumeService resumeService;

    //新增
    @RequestMapping("addResume")
    @ResponseBody
    public void addResume(Resume resume,HttpServletRequest request){
        User user =(User) request.getSession().getAttribute("user");
        resume.setUserId(user.getUserId());
        resumeService.addResume(resume);
    }

    //修改
    @RequestMapping("updateResume")
    @ResponseBody
    public void updateResume(Resume resume){
        resumeService.updateResume(resume);
    }

    //查询
    @RequestMapping("getResume")
    @ResponseBody
    public Resume getResume(HttpServletRequest request){
        User user =(User) request.getSession().getAttribute("user");
        return resumeService.getResume(user.getUserId());
    }

    //招聘者查询简历
    @RequestMapping("getResume1")
    //@ResponseBody
    public String getResume1(Integer positionId, Integer userId, Model model){

        Resume resume = resumeService.getResume(userId);
        model.addAttribute("resume",resume);
        return "mine/getjl";
    }

}
